//AI投降，直到玩家靠近，放下武器
//或者周围没有玩家，解除状态

if(!alive _this) exitWith{};

moveOut _this;
uiSleep 0.5;

private _civ_group = createGroup [civilian, true];

[_this] joinSilent _civ_group;

[_this,"Acts_JetsShooterNavigate_loop"]remoteExec["switchMove",0];
[_this,"Acts_JetsMarshallingStop_loop"]remoteExec["playMove",0];//Acts_JetsMarshallingStop_loop
//ApanPknlMstpSnonWnonDnon
//超过50人，就变为自爆兵
if(as_captive_kill_num > 50) then
{
	[_this,5] spawn fn_bomberAI;
};

private _end = false;

while {!_end}do
{
	uiSleep 10;
	if(!alive _this) exitWith{_end = true};
	
	//此处不能用fn_getPlayerAttack函数，因为as_captive_group没有玩家的信息
	private _player = [_this, 200] call fn_getPlayerNear;
	if(isNull _player) then
	{
		_player = [_this, 400] call fn_getPlayerNear;
		if(isNull _player) then
		{//重新武装，且结束逻辑
			[_this,""]remoteExec["switchMove",0];
			[_this] joinSilent as_group_g;
			_end = true;
		};
	}
	else
	{
		if(_player distanceSqr _this < 100) then
		{//放下武器结束逻辑
			
			[_this,""]remoteExec["switchMove",0];
			
			//放下武器
			private _wh = "GroundWeaponHolder_Scripted" createVehicle position _this;
			{
				_this action ["DropWeapon", _wh, currentWeapon _this];
				uiSleep 3;
			}forEach weapons _this;
			
			//放下背包
			{
				_this unassignItem _x;
			}forEach assignedItems _this;
			 
			_this action ["DropBag", _wh, backpack _this];
			
			//头盔
			//(headgear _this) createVehicle _wh;
			//removeHeadgear _this;
			
			uiSleep 3;
			//_player action ["Surrender", _this];
			[_this,"ApanPknlMstpSnonWnonDnon_G01"]remoteExec["playMove",0];
			_end = true;
			
			//添加俘虏被杀计数
			_this addEventHandler ["killed", 
			{
				private _killer = _this select 1;
				if(isPlayer _killer) then{as_captive_kill_num = as_captive_kill_num + 1;}
			}];
		};
	};
};



